﻿using System;
using System.Collections.Generic;
using System.Text; 
using System.Security.Cryptography;
using System.Linq;
namespace TL_Cloud.Utils
{
    public class RebexRegister
    {
        /// <summary>
        /// key的结束日期到2033-7-1
        /// </summary>
        private const string conKey = "[{\"StartDate\":\"2018-09-18\",\"EndDate\":\"2018-11-17\",\"key\":\"==AktF4Q6Voh05hFnpp+dbuJyoFJPRCxCor0F5IJhVVQtk==\"},{\"StartDate\":\"2018-11-17\",\"EndDate\":\"2019-01-16\",\"key\":\"==AMUMkkBvi58/koTHphGQ4psQMDrn8MH2jlK/ihkAr0TM==\"},{\"StartDate\":\"2019-01-16\",\"EndDate\":\"2019-03-17\",\"key\":\"==AL+oQU7wWzNxagYEB8eQZsEwVpe0pC+XHbd0UlO7R4VI==\"},{\"StartDate\":\"2019-03-17\",\"EndDate\":\"2019-05-16\",\"key\":\"==AIpFkJ3Eg54UIQG92BAOrjHc+SljJUFeqjxMGIpcrAAw==\"},{\"StartDate\":\"2019-05-16\",\"EndDate\":\"2019-07-15\",\"key\":\"==ADO5AX1QOKpL0gcUeFReKQDWGaWGojG0ulJbT67vuTiQ==\"},{\"StartDate\":\"2019-07-15\",\"EndDate\":\"2019-09-13\",\"key\":\"==ANGfp4MImwgv17ydoDUWgN+kHOAsFYbCQV4o8b5horSE==\"},{\"StartDate\":\"2019-09-13\",\"EndDate\":\"2019-11-12\",\"key\":\"==ApaKlwX6TD6nqu347FBJDZ/4ZDZumAb/g87AH5aFwEOg==\"},{\"StartDate\":\"2019-11-12\",\"EndDate\":\"2020-01-11\",\"key\":\"==AOw8stxGg/clN+l1VuBgxcrE8z4hnt5TCC3W3X7Xo94I==\"},{\"StartDate\":\"2020-01-11\",\"EndDate\":\"2020-03-11\",\"key\":\"==AC0MznxuzyYpPiVklc7D/qa5UUcH9K3LovU8KhA5zNbc==\"},{\"StartDate\":\"2020-03-11\",\"EndDate\":\"2020-05-10\",\"key\":\"==APO8/GVMFrVCSohnpUNvbewFhJTHbqrC/qDHcJlOKcBk==\"},{\"StartDate\":\"2020-05-10\",\"EndDate\":\"2020-07-09\",\"key\":\"==AoCKHJ4CrgF6xaIHqr8h74yH28jhnWay0sHmOP8rtUac==\"},{\"StartDate\":\"2020-07-09\",\"EndDate\":\"2020-09-07\",\"key\":\"==AS9V4DkIRYHyk4+D/UQfNAc4MfNmwlHlOP9YVYAaygMk==\"},{\"StartDate\":\"2020-09-07\",\"EndDate\":\"2020-11-06\",\"key\":\"==ApEDwEbTKPTmGmpkv9vKD30AmFzd+wLcY4InZBXu7YBY==\"},{\"StartDate\":\"2020-11-06\",\"EndDate\":\"2021-01-05\",\"key\":\"==AV6RK/ggbL2y5AFsuLDX7RsItZtKo/tm2Ke9ZnZaKA7w==\"},{\"StartDate\":\"2021-01-05\",\"EndDate\":\"2021-03-06\",\"key\":\"==AbtfpuE44lIpYgICdROuROW03C5YY76aZT2pogBNyhYU==\"},{\"StartDate\":\"2021-03-06\",\"EndDate\":\"2021-05-05\",\"key\":\"==AciaQh7zknE2Zx0ludLjKjGcFMJIUqSbiA+7lNodDv7c==\"},{\"StartDate\":\"2021-05-05\",\"EndDate\":\"2021-07-04\",\"key\":\"==ANPUASL5ftgNsDNEE+Yz6yuBax715/YCrdAVrJgE1eLY==\"},{\"StartDate\":\"2021-07-04\",\"EndDate\":\"2021-09-02\",\"key\":\"==AsVQH+Qov4GXpa/XKmWzUuaB9miUbtS3NinCT8/c2TIY==\"},{\"StartDate\":\"2021-09-02\",\"EndDate\":\"2021-11-01\",\"key\":\"==AIeCeMZwSodYCgG+4Q7RA5Hp48wt100IhRabS81u3B+Y==\"},{\"StartDate\":\"2021-11-01\",\"EndDate\":\"2021-12-31\",\"key\":\"==A9tLus75xVKX1gLVS7mqU/iWZc3IeC16nC/9Z3jvehQ===\"},{\"StartDate\":\"2021-12-31\",\"EndDate\":\"2022-03-01\",\"key\":\"==AdoAR1VOeZvms4tez+T+iGArpxruyVupIAKyzVOF8Q04==\"},{\"StartDate\":\"2022-03-01\",\"EndDate\":\"2022-04-30\",\"key\":\"==AXxkc2FAtsHAench+0rCq+GpEqS0zBfKbTmb/g0gNZTU==\"},{\"StartDate\":\"2022-04-30\",\"EndDate\":\"2022-06-29\",\"key\":\"==AeIDz+O0SzqiOs2YQuqVl+BKfc7sqpxGS4+LR31ncoTg==\"},{\"StartDate\":\"2022-06-29\",\"EndDate\":\"2022-08-28\",\"key\":\"==AFWSVI46c+9KH5i9SwautQQ8N+NPOEk3nez0rOCKd4tg==\"},{\"StartDate\":\"2022-08-28\",\"EndDate\":\"2022-10-27\",\"key\":\"==AV4SfY7Jpqs8dbcE8f428TFWrpVmsoMIUcc29WTjsbbo==\"},{\"StartDate\":\"2022-10-27\",\"EndDate\":\"2022-12-26\",\"key\":\"==AXnITNdq44cjH8Fq96iD0qTkMd7WxESX84xmGYoWi7PA==\"},{\"StartDate\":\"2022-12-26\",\"EndDate\":\"2023-02-24\",\"key\":\"==A7iJsKIJRlcDdOX7H1r97dqU8LLGcazXnxDyuwrRPYA===\"},{\"StartDate\":\"2023-02-24\",\"EndDate\":\"2023-04-25\",\"key\":\"==AMB0Rgugte2Dr09PgQw1zmkud+sVMkbuFpB2ci8sNKNY==\"},{\"StartDate\":\"2023-04-25\",\"EndDate\":\"2023-06-24\",\"key\":\"==AD8m/QElsmdgmKJDoq83KoVqyBtbqBx1Nv6rTs1NStUU==\"},{\"StartDate\":\"2023-06-24\",\"EndDate\":\"2023-08-23\",\"key\":\"==Asx7hnZJGwxCEkT2gFxjSV6GYRQweJSxTPpaneg4KKB4==\"},{\"StartDate\":\"2023-08-23\",\"EndDate\":\"2023-10-22\",\"key\":\"==Ap320w+FJbg2inFkUud/b2ZRH1O6FgP89MQAxsJieeZ0==\"},{\"StartDate\":\"2023-10-22\",\"EndDate\":\"2023-12-21\",\"key\":\"==AgprW9/FPr58p6P/o93/xW6rp97zCGEuAawoJereI+hw==\"},{\"StartDate\":\"2023-12-21\",\"EndDate\":\"2024-02-19\",\"key\":\"==AjP6nLk6b8qjbJw+Ddpo+VPQm/Xn8wcIOASWNZ3740c0==\"},{\"StartDate\":\"2024-02-19\",\"EndDate\":\"2024-04-19\",\"key\":\"==AcUruUspzS0voAJ5yLOrfYgj8GEcv39JDBixrk9Nze2k==\"},{\"StartDate\":\"2024-04-19\",\"EndDate\":\"2024-06-18\",\"key\":\"==Amv2UGdYrhKxneZdvZZvh08kzkiTYEzA7fkLwRDRpxfE==\"},{\"StartDate\":\"2024-06-18\",\"EndDate\":\"2024-08-17\",\"key\":\"==AP2lwUEPy0ecmuZjYLInCrS3y8EZRru0oIOJ2+XkXjts==\"},{\"StartDate\":\"2024-08-17\",\"EndDate\":\"2024-10-16\",\"key\":\"==AFQp77O4d827mohTGJWYJzrLoFVKahCPFdWB3/jhfM9Q==\"},{\"StartDate\":\"2024-10-16\",\"EndDate\":\"2024-12-15\",\"key\":\"==AHKeqg3B52hYl6bQ9QqzTDWHC9OgAH6Tl2J/4uYvdv6g==\"},{\"StartDate\":\"2024-12-15\",\"EndDate\":\"2025-02-13\",\"key\":\"==AshYO+oshiq7IL4m8jU2ySocukcxhkzBdGzw7NX55WEU==\"},{\"StartDate\":\"2025-02-13\",\"EndDate\":\"2025-04-14\",\"key\":\"==AJNuaOhlScEomNIbKnvrNlJFGBrnem0h2TJcXYNpMSYA==\"},{\"StartDate\":\"2025-04-14\",\"EndDate\":\"2025-06-13\",\"key\":\"==AX4AtbWjEJi8uCPVAE9LpDLc2diPz4BfBtD3QNufmhkk==\"},{\"StartDate\":\"2025-06-13\",\"EndDate\":\"2025-08-12\",\"key\":\"==AJJ1coBr7sGv3h8HrU+IgmIOrVsYJXrEYQHNXmo9HTJs==\"},{\"StartDate\":\"2025-08-12\",\"EndDate\":\"2025-10-11\",\"key\":\"==AaqbkqbbYfEMrjECTMZL9mTa2Ta8GigxSQBz2ousREPs==\"},{\"StartDate\":\"2025-10-11\",\"EndDate\":\"2025-12-10\",\"key\":\"==AFvOPREpClHS9Y9jW+7b28ETv3C5SczY1V/t7L0DBW+w==\"},{\"StartDate\":\"2025-12-10\",\"EndDate\":\"2026-02-08\",\"key\":\"==AS6arZbaKq5wfXrGlYwbIoHk9dhBPTgEwHX27IgG9OK0==\"},{\"StartDate\":\"2026-02-08\",\"EndDate\":\"2026-04-09\",\"key\":\"==AVJz6NvHbo8H3YNtR/DihpEgPaUwrNKtuKxOvEIw715k==\"},{\"StartDate\":\"2026-04-09\",\"EndDate\":\"2026-06-08\",\"key\":\"==AoPor74O00HiwWDBp3pCi4lH07PbyOK8oHIZ/ixAV7nM==\"},{\"StartDate\":\"2026-06-08\",\"EndDate\":\"2026-08-07\",\"key\":\"==Amazlf9xXy0r0JeHxlot7npgl5LXeVmCTPtuuNRiujro==\"},{\"StartDate\":\"2026-08-07\",\"EndDate\":\"2026-10-06\",\"key\":\"==AQkjsc8caPws9k0RevHKov3AkLhpA+0CJTcRMnq70fF8==\"},{\"StartDate\":\"2026-10-06\",\"EndDate\":\"2026-12-05\",\"key\":\"==ArsOZNABIx3vXRe3iU9fZsm35OO23dZcG8bTUrDZe6vM==\"},{\"StartDate\":\"2026-12-05\",\"EndDate\":\"2027-02-03\",\"key\":\"==Acch6yuzgCpzX0mJXCRAi4Exjjz2KXLpY1Gj9bthnfNY==\"},{\"StartDate\":\"2027-02-03\",\"EndDate\":\"2027-04-04\",\"key\":\"==AKv3bGiW+Z8/JAzIdRZi2fCGU2is41axZ+1BHQNoRrEo==\"},{\"StartDate\":\"2027-04-04\",\"EndDate\":\"2027-06-03\",\"key\":\"==AQ6S1YjCDEpEtL21R+nv2xVj5cdFWzLiN5mCZOT8cFBc==\"},{\"StartDate\":\"2027-06-03\",\"EndDate\":\"2027-08-02\",\"key\":\"==AKyxJ13yWKRZH4s1IFiywr6F7tX/WrJBpXKS87B3+yoU==\"},{\"StartDate\":\"2027-08-02\",\"EndDate\":\"2027-10-01\",\"key\":\"==AOy2VA61CouhbNYLiHy+P1O33poy1YYzi8UmvSfdOHB4==\"},{\"StartDate\":\"2027-10-01\",\"EndDate\":\"2027-11-30\",\"key\":\"==An8W5CIK/5Rg36S30QjVrWLXn+qjiPt2Zky/GSUfji6g==\"},{\"StartDate\":\"2027-11-30\",\"EndDate\":\"2028-01-29\",\"key\":\"==ARdcWmwz56DAhYhVBvVdaQe/QkY9pavuqryhYkiefEao==\"},{\"StartDate\":\"2028-01-29\",\"EndDate\":\"2028-03-29\",\"key\":\"==AR99041Qp3BeUcp+wLm7sspfGLZVm2ldM7zoCqT648W4==\"},{\"StartDate\":\"2028-03-29\",\"EndDate\":\"2028-05-28\",\"key\":\"==AVLPTDnmf8IgMdL7IGvpUQZAbsoXoYE2vNUD6uWQhad4==\"},{\"StartDate\":\"2028-05-28\",\"EndDate\":\"2028-07-27\",\"key\":\"==AmhhIpZc2Pc4+NdERqymCa+Nf4skKacJrUg8+Fm6AbDs==\"},{\"StartDate\":\"2028-07-27\",\"EndDate\":\"2028-09-25\",\"key\":\"==AFNJmC9jV+qYcdBhTQl/M8SdEnW4l0b/HoCiQOmCJ6cE==\"},{\"StartDate\":\"2028-09-25\",\"EndDate\":\"2028-11-24\",\"key\":\"==Aicn6VzqCM9q+RJWhv2NvRrV2SUQy91QCzk/0O7UJW6c==\"},{\"StartDate\":\"2028-11-24\",\"EndDate\":\"2029-01-23\",\"key\":\"==AYL9dFeB+PZpGFUB7YM5hHom0JkiitFzXDxD5sWYRIIQ==\"},{\"StartDate\":\"2029-01-23\",\"EndDate\":\"2029-03-24\",\"key\":\"==AGTKZGbmwFt15XKMK3dhgPE1voeIhy22ReKm+U/tCt50==\"},{\"StartDate\":\"2029-03-24\",\"EndDate\":\"2029-05-23\",\"key\":\"==APMdP2MM/Huo8kNnnuTYqN40mRmyjfAGYAnrvsTMWrzQ==\"},{\"StartDate\":\"2029-05-23\",\"EndDate\":\"2029-07-22\",\"key\":\"==AtYWBbAeOrFKscI8r8I7hYyZ42IQBPevOatn7NcDTX3Y==\"},{\"StartDate\":\"2029-07-22\",\"EndDate\":\"2029-09-20\",\"key\":\"==ATGEEcGDIcoVymHDKkldh5W1PSxwuR1F5f5gksZ94kMU==\"},{\"StartDate\":\"2029-09-20\",\"EndDate\":\"2029-11-19\",\"key\":\"==ACJ4bmyK7eOEU0fUfrWRIwl0Gf7ZZP2889ccQdTshyaw==\"},{\"StartDate\":\"2029-11-19\",\"EndDate\":\"2030-01-18\",\"key\":\"==Ab4lClCZj3GU7ykLIBMyO3m3q8/GtzBUBSo0MlDJNGYw==\"},{\"StartDate\":\"2030-01-18\",\"EndDate\":\"2030-03-19\",\"key\":\"==AUPxJztfLF0VLm6P3bGQd5SgH1dslQg/xWCyA4/jaUoA==\"},{\"StartDate\":\"2030-03-19\",\"EndDate\":\"2030-05-18\",\"key\":\"==AaiR6QamMS4VsJ3YkftHq/0FbtCu8WHPW86Szb3Ofbqc==\"},{\"StartDate\":\"2030-05-18\",\"EndDate\":\"2030-07-17\",\"key\":\"==APHY6FagqVKljpgLOyJqn1+wNAGOfTAw9SidwYppCyYs==\"},{\"StartDate\":\"2030-07-17\",\"EndDate\":\"2030-09-15\",\"key\":\"==An0yTBzJTMIqewYORLlZreQclrnZIdIPkbLhQeqiIHAA==\"},{\"StartDate\":\"2030-09-15\",\"EndDate\":\"2030-11-14\",\"key\":\"==AF8EaM78mx5frA1dWucbPbaWjpqRF2gfeZGj6+K+3C6U==\"},{\"StartDate\":\"2030-11-14\",\"EndDate\":\"2031-01-13\",\"key\":\"==AXEVsqqXBd/unV1/J2Y2k7qksNxWxV4/tvbsimx1ozgw==\"},{\"StartDate\":\"2031-01-13\",\"EndDate\":\"2031-03-14\",\"key\":\"==AfqQYe6HWdoUVy+FOpkwdbVDYMc0NEO55sQBzoGbqxkM==\"},{\"StartDate\":\"2031-03-14\",\"EndDate\":\"2031-05-13\",\"key\":\"==ASqGFfa+5EgNtuGQNh0QEOyhMP6dfgnFFuXPWVlBJ8XA==\"},{\"StartDate\":\"2031-05-13\",\"EndDate\":\"2031-07-12\",\"key\":\"==ANbtOGAjWquj83a3sU9/6Hso0F+7r4INjP1oYxO8KZv8==\"},{\"StartDate\":\"2031-07-12\",\"EndDate\":\"2031-09-10\",\"key\":\"==AJ+Ui/pC6Mg05TaEr3+aCJaqB3NXNBy4YamZIzSu4VOY==\"},{\"StartDate\":\"2031-09-10\",\"EndDate\":\"2031-11-09\",\"key\":\"==AfjToN4prxyXbN3AQiGWyY0pM1OTUxaEk/RaegTDb86Q==\"},{\"StartDate\":\"2031-11-09\",\"EndDate\":\"2032-01-08\",\"key\":\"==AWn7bIBTh8kxRH3ejq7PKiOGuHqGRNWQt5rhy0BcG5sg==\"},{\"StartDate\":\"2032-01-08\",\"EndDate\":\"2032-03-08\",\"key\":\"==AthsVIymOs9s7+KfdzFJE6cKHL092XYknQyXGLapGITc==\"},{\"StartDate\":\"2032-03-08\",\"EndDate\":\"2032-05-07\",\"key\":\"==APPkM69J2/3xVBTofbajAPyy0t+Ej2VH2f+MoIZOArGg==\"},{\"StartDate\":\"2032-05-07\",\"EndDate\":\"2032-07-06\",\"key\":\"==AY7kF3F5yBJ/f9EYcV6LVY9w7EgAbjuR64U7L14i5618==\"},{\"StartDate\":\"2032-07-06\",\"EndDate\":\"2032-09-04\",\"key\":\"==AIMV6fh4l/y8IccV+JuzA0RDbPgDrLhKfPxTnxZ9KpR0==\"},{\"StartDate\":\"2032-09-04\",\"EndDate\":\"2032-11-03\",\"key\":\"==ABDFGiP70D0vNh7u3SMunL4Ksxhuuvk+ffyLb2tb/D6U==\"},{\"StartDate\":\"2032-11-03\",\"EndDate\":\"2033-01-02\",\"key\":\"==ADBTJxZLhGvcipN//fEbASqjLhGB1IorT6OWgQSkqVrA==\"},{\"StartDate\":\"2033-01-02\",\"EndDate\":\"2033-03-03\",\"key\":\"==ApFNgue+K/V6oDai4k0//wQJeomReIecJZRmuPeIY00o==\"},{\"StartDate\":\"2033-03-03\",\"EndDate\":\"2033-05-02\",\"key\":\"==AnR0XnOuaugeC+2H0z5a3kPudZdyx3uXzgQrIt3EMrPA==\"},{\"StartDate\":\"2033-05-02\",\"EndDate\":\"2033-07-01\",\"key\":\"==Aa9w2v2NeN4FF/7V3m7axs3K2tNtHEXTbkp0H1zKDiXc==\"}]";


        private static DateTime? CreateDate = null;
        private static string calckKey = "";

        public static string GetRegisterCode()
        {
            if (CreateDate != null && CreateDate.Value.Date == DateTime.Now.Date)
            {
                return calckKey;
            }
            else
            {
                List<RebexKey> lstKeys = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RebexKey>>(conKey);
                var key = lstKeys.FirstOrDefault(n => Convert.ToDateTime(n.StartDate).Date >= DateTime.Now.Date && Convert.ToDateTime(n.EndDate) <= DateTime.Now.Date);
                if (key == null)
                {
                    return "";
                }
                else
                {
                    CreateDate = DateTime.Now;
                    calckKey = key.key;
                    return key.key;
                }
            }
        }

        public class RebexKey
        {
            public string StartDate { get; set; }

            public string EndDate { get; set; }
            public string key { get; set; }
        }
    }
}
